package com.headingdata.define;

public class ArrayDemo1 {
    public static void main(String[] args) {
        //静态初始化数组
        int[] ages = new int[]{12,23,26};
        double[] scores = new double[]{88.5,89.5,96};

        //简化写法
        int[] ages1 = {12,23,26};
        double[] scores1 = {88.5,89.5,96};

        System.out.println(ages);
        System.out.println(scores1);

        System.out.println(ages[0]);
        System.out.println(ages[1]);
        System.out.println(ages[2]);

        ages[0] = 54;
        ages[2] = 90;
        System.out.println(ages[0]);
        System.out.println(ages[1]);
        System.out.println(ages[2]);
        System.out.println(ages.length);

        for (int i = 0;i < ages.length;i++){
            System.out.println(ages[i]);
        }
        double sum = 0;
        for (int i = 0;i < scores.length;i++){
            sum += scores[i];
        }
        System.out.println(sum);

    }
}
